<template>
	<view class="content">
		<view class="input-group">
			<view class="input-row">
				<text class="title">新密码：</text>
				<m-input type="text" focus clearable v-model="pwd1" placeholder="输入新密码"></m-input>
			</view>

			<view class="input-row">
				<text class="title">确认输入：</text>
				<m-input type="text" focus clearable v-model="pwd2" placeholder="输入新密码"></m-input>
			</view>
		</view>

		<view class="btn-row">
			<button type="primary" class="primary" @tap="findPassword">提交</button>
		</view>
	</view>
</template>

<script>
	import service from '../../service.js';
	import mInput from '../../components/m-input.vue';

	export default {
		components: {
			mInput
		},
		data() {
			return {
				pwd1: '',
				pwd2: ''
			}
		},
		methods: {
			findPassword() {
				/**
				 * 仅做示例
				 */
				if (this.pwd1 != this.pwd2) {
					uni.showToast({
						icon: 'none',
						title: '2次输入的密码不一致',
					});
					return;
				}
				if (this.pwd1.length < 6) {
					uni.showToast({
						icon: 'none',
						title: '密码不能少于6位',
					});
					return;
				}
				this.changePwd(this.pwd1)
			},
			changePwd(pwd) {
				this.$http.hlChangePwd(pwd).then(ret => {
					if (ret.status === 1) {

						uni.showToast({
							title: ret.msg,
							mask: false,
							duration: 1500
						});
						uni.reLaunch({
							url: '../main/main',
						});
					} else {
						uni.showToast({
							title: ret.msg,
							mask: false,
							duration: 1500
						});
					}
				})
			}
		}
	}
</script>

<style>

</style>
